package com.show.mytest;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

public class Test06_Properties {
    public static void main(String[] args) throws Exception {
        // 创建属性集合
        Properties pp = new Properties();
        // 添加数据到集合
        pp.setProperty("driver","com.mysql.jdbc.Driver");
        pp.setProperty("url","jdbc:mysql:///mybatis?characterEncoding=utf8");
        pp.setProperty("username","root");
        pp.setProperty("password","admin");
        pp.setProperty("initialSize","5");
        pp.setProperty("maxActive","10");
        // 创建字节输出流
        FileOutputStream fos = new FileOutputStream("F:/jdbc.properties");
        // 将属性集写入输出流
        pp.store(fos,"jdbc");
        // 创建第二个属性集
        Properties pp1 = new Properties();
        // 创建字节输入流对象
        FileInputStream fis = new FileInputStream("F:/jdbc.properties");
        // 读取流
        pp1.load(fis);
        // 输出属性集
        System.out.println(pp1);
        // 关闭流
        fos.close();
        fis.close();
    }
}
